package com.tonoinfo.convert;

import com.tonoinfo.dto.RoleDTO;
import com.tonoinfo.entity.Role;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

/**
 * 角色转换
 * @author shuang.cheng
 * @date 2022/5/7
 */
@Mapper(componentModel = "spring")
public interface RoleConvert {

    /**
     * Role转成RoleDTO
     * @param role
     * @return
     */
    @CommonConvert
    @Mapping(source = "roleName", target = "roleName2")
    RoleDTO role2RoleDTO(Role role);

    /**
     * RoleDTO转成Role
     * @param roleDTO
     * @return
     */
    @InheritInverseConfiguration(name = "role2RoleDTO")
    Role roleDTO2Role(RoleDTO roleDTO);
}
